package com.xingda.packing.dmss.minitor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xingda.packing.dmss.common.dto.PageDto;
import com.xingda.packing.dmss.minitor.entity.PkEvents;
import com.xingda.packing.dmss.minitor.mapper.PkEventsMapper;
import com.xingda.packing.dmss.minitor.service.IPkEventsService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author anxiaoning
 * @since 2021-07-03
 */
@Service
public class PkEventsServiceImpl extends ServiceImpl<PkEventsMapper, PkEvents> implements IPkEventsService {

    @Override
    public Page<PkEvents> getPkEventsPage(PageDto dto) {
        LambdaQueryWrapper<PkEvents> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.ge(PkEvents::getCreateTime, dto.getStart());
        lambdaQueryWrapper.lt(PkEvents::getCreateTime, dto.getEnd());
        lambdaQueryWrapper.eq(dto.getArea() != 0, PkEvents::getArea, dto.getArea());
        lambdaQueryWrapper.orderByDesc(PkEvents::getCreateTime);
        Page<PkEvents> page = new Page<>(dto.getCurrent(), dto.getPagesize());
        this.baseMapper.selectPage(page, lambdaQueryWrapper);
        return page;
    }

}
